<template>
  <div class="page-error">
    <div class="container-layout">
      <i class="el-icon-warning waringIcon" />
      <p class="tips">提示</p>
      <p class="texts">{{ errorTips }}</p>
      <div class="button" @click="submit">确定</div>
    </div>
  </div>
</template>

<script>
import { loginUrl } from "@/api";
export default {
  data() {
    const pageData =
      typeof window.pageData === "object"
        ? window.pageData
        : {
            forbiddenLogin: false,
          };
    return {
      msg: "",
      pageData,
    };
  },
  computed: {
    errorTips() {
      return this.msg ? this.msg : "您的登录已过期，请在刷新后重新登录。";
    },
  },
  created() {
    if (this.pageData.forbiddenLogin) {
      this.msg = "当前账号没有权限登录，请更换账号";
    } else if (this.$route.query) {
      this.msg = this.$route.query.msg;
    }
  },
  mounted() {
    // 页面被刷新,进入登录页。首次进入不跳转
    if (window.performance.navigation.type == 1) {
      window.location.href = loginUrl;
    }
  },
  methods: {
    submit() {
      window.location.href = loginUrl;
    },
  },
};
</script>

<style lang="less" scoped>
.page-error {
  background: rgba(0, 0, 0, 0.3);
  width: 100vw;
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  .container-layout {
    width: 600px;
    height: 343px;
    background: #ffffff;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    .waringIcon {
      color: #2c7dfa;
      font-size: 63px;
    }
    .tips {
      text-align: center;
      font-size: 20px;
      line-height: 21px;
      color: #2b313c;
      font-weight: bold;
      margin: 11px 0 20px;
    }
    .texts {
      text-align: center;
      font-size: 18px;
      line-height: 21px;
      color: #5d6574;
      margin: 0 0 53px;
    }
    .button {
      cursor: pointer;
      width: 110px;
      height: 40px;
      line-height: 40px;
      color: #ffffff;
      font-size: 16px;
      border-radius: 2px;
      text-align: center;
      background: #2c7dfa;
    }
  }
}
</style>
